package JZ63_数据流中的中位数;

import java.util.ArrayList;

public class Solution {
    ArrayList<Integer> list = new ArrayList<>();

    public void Insert(Integer num) {
        list.add(num);
    }

    public Double GetMedian() {
        list.sort(Integer::compareTo);
        int index = list.size() / 2;
        if (list.size() % 2 != 0){
            return (double)list.get(index);
        }else {
            return (list.get(index - 1) + (double)list.get(index));
        }
    }


}